<script lang="ts" setup>
import { ref } from "vue"
import {companyInfoGetSwipeSerive,companyInfoGetListSerive} from '@/api/company.js'

import { baseURL } from "@/utils/request"
const tableData = ref([])
const tableData1 = ref([])
interface SwipeItem {  
  id: number;  
  name:string;
  imageUrl: string;  
  // 其他可能需要的属性，如title  
}  
const content2 = ref<string>('')
const content3 = ref<string>('')
const content4 = ref<string>('')
const content5 = ref<string>('')
const swipe = ref<SwipeItem[]>([]);

interface ListItem {
  id:number
  content:string
}
const List = ref<ListItem[]>([])
const getList = async()=>{
  const res = await companyInfoGetListSerive()
  List.value = res.data.data
  content2.value = List.value[1]?.content || ''
  content3.value = List.value[2]?.content || ''
  content4.value = List.value[3]?.content || ''
  content5.value = List.value[4]?.content || ''   
}
getList()
const getSwipeList = async()=>{
  const res =  await companyInfoGetSwipeSerive()
  swipe.value = res.data.data
  ElMessage.success('获取轮播图信息成功！') 
}
getSwipeList()
const changeUrl = (url:string)=>{
   return baseURL + url
}
</script>

<template>
    
     <div class="top"> 
     <el-card >
       <el-carousel :interval="4000" type="card" height="200px">
       <el-carousel-item v-for="item in swipe" :key="item.id">
      <img :src="changeUrl(item.imageUrl)" :alt="item.name" >
      <h3 text="2xl" justify="center">{{ item }}</h3>
     </el-carousel-item>
    </el-carousel>
    </el-card>
     </div>
     

    <div class="center">
    <el-card>
        <div class="center-wrapped">
         <div>
           <el-link>公司介绍</el-link>
        <el-text line-clamp="3" truncated class="indent-content">
          {{ content2 }}
        </el-text>
         </div>
         <div>
           <el-link>公司架构</el-link>
        <el-text line-clamp="3" truncated class="indent-content">
             {{ content3 }}
        </el-text>
         </div>
        <div>
           <el-link underline>公司战略</el-link>
        <el-text line-clamp="3" truncated class="indent-content">
             {{ content4 }}
        </el-text>
        </div>
         <div>
        <el-link>公司高层</el-link>
         <el-text line-clamp="3" truncated class="indent-content">
             {{ content5 }}
        </el-text>
         </div>
    </div>

    </el-card>
    </div>
    <div class="footer">
        <el-card>
            <div class="footer-wrapped">
                <div class="left">
                    <h3>公司公告</h3>
                      <el-table :data="tableData" style="width: 100%">
                      <el-table-column prop="date" label="公告主题" width="180" />
                      <el-table-column prop="name" label="级别" width="180" />
                      <el-table-column prop="name" label="发布部门" width="180" />
                      <el-table-column prop="name" label="发布时间" width="180" />
                       <template #empty>
                          <el-empty description="无公司公告" :image-size="40" />
                      </template>
                      </el-table>

                    
                </div>
                <div class="right">
                    <h3>系统消息</h3>
                    <el-table :data="tableData1" style="width: 100%">
                      <el-table-column prop="date" label="公告主题" width="180" />
                      <el-table-column prop="name" label="级别" width="180" />
                      <el-table-column prop="name" label="发布部门" width="180" />
                      <el-table-column prop="name" label="发布时间" width="180" />
                       <template #empty>
                          <el-empty description="无系统公告" :image-size="40"  />
                      </template>
                      </el-table>

                </div>
            </div>
        </el-card>
    </div>
</template>

<style lang="scss" scoped>
.top{
  .el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;

}
img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
}
.center{
    margin: 5px 0;
    .center-wrapped{
        height: 200px;
        display: flex;
        justify-content:space-between;
        align-items: center;
        div{

          height: 100%;
          width: 24%;
          margin: 0 10px;
          .el-link{
            font-size: 16px;
            height: 40px;
            line-height: 40px;
       
            
          }
          .el-text{
            height: 140px;
            width: 100%;
            background-color:#f5f5f5;
          }
          /* 定义首行缩进样式 */
.indent-content {
  display: block;
  text-indent: 2em; /* 首行缩进两个字符 */
}

/* 深度选择器处理Element UI内部样式 */
::v-deep .el-text__content {
  text-indent: inherit; /* 继承缩进样式 */
}
        }
        
    }
}
.footer{
    .footer-wrapped{
      height: 230px;
        display: flex;
        justify-content: flex-start;
        .left{
          margin-right:10px ;
          width: 49%;
          background-color: #f5f5f5;
          .el-table{
                      background-color: #f5f5f5;
          }
        }
        .right{
          width: 49%;
          background-color: #f5f5f5;
          .el-table{
                      background-color: #f5f5f5;
          }
        }
        .el-empty{
          width: 100%;
          height: 180px;
        }
    }
}
:deep(.el-card__body){
  padding: 0 10px;
}
:deep(.el-table__empty-block){
  height: 100%;
  width: 100%;
}
</style>